/**
 * 
 */
package travibot.model.positions;

import travibot.model.DevelopedPosition;
import travibot.model.Position;
import travibot.model.Structure;

/**
 * @author Petr Macek
 * 
 */
public class DevelopedPositionImpl implements DevelopedPosition {

    private final int id;

    private Structure structure;

    private final Position.Type type;

    public DevelopedPositionImpl(int id, Type type) {

        super();
        this.id = id;
        this.type = type;
    }

    /**
     * Returns the structure that has been built over this position.
     * 
     * @return
     */
    public Structure getBuiltStructure() {

        return structure;
    }

    /*
     * (non-Javadoc)
     * 
     * @see travibot.engine.Position#getId()
     */
    public int getId() {

        return id;
    }

    /*
     * (non-Javadoc)
     * 
     * @see travibot.engine.Position#getType()
     */
    public Type getType() {

        return type;
    }

    /*
     * (non-Javadoc)
     * 
     * @see travibot.engine.Position#isDeveloped()
     */
    public boolean isDeveloped() {

        return true;
    }

    /**
     * Sets the structure that has been built over this position
     * 
     * @param structure
     */
    public void setStructure(Structure structure) {

        this.structure = structure;
    }

    @Override
    public boolean equals(Object obj) {

        boolean ret = false;
        if (obj instanceof Position) {
            if (((Position)obj).getId() == id) {
                ret = true;
            }
        }
        return ret;
    }

    @Override
    public int hashCode() {

        return String.valueOf(id).hashCode();
    }

}
